Skip to content

Conversation

@vprashar2929
Copy link
Collaborator

@vprashar2929 vprashar2929 commented Oct 25, 2025

Implement OpenSSF scorecard security recommendations to
improve workflow security

  • Set default read-all permissions at the workflow level
    across all workflows
  • Define minimal job-level permissions following least privilege
    principle
  • Refactor release workflow to separate build and release steps
  • Add scorecard job to PR checks workflow
  • Reduce artifact retention to 1 day for scorecard results

@github-actions github-actions bot added the chore Routine tasks or maintenance label Oct 25, 2025
runs-on: ubuntu-latest
steps:
- name: Download Release Artifacts
uses: actions/download-artifact@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
Implement OpenSSF scorecard security recommendations to
improve workflow security

- Set default  `read-all` permissions at the workflow level
  across all workflows
- Define minimal job-level permissions following least privilege
  principle
- Refactor release workflow to separate build and release steps
- Add scorecard job to PR checks workflow
- Reduce artifact retention to 1 day for scorecard results

Signed-off-by: vprashar2929 <[email protected]>
@github-actions github-actions bot added ci Changes to the CI pipeline and removed chore Routine tasks or maintenance labels Nov 3, 2025
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 0: GitHub-owned GitHubAction not pinned by hash
Remediation tip: update your workflow using https://app.stepsecurity.io
Click Remediation section below for further remediation help
@vprashar2929 vprashar2929 changed the title chore: resolve scorecard checks ci: harden github actions permissions for scorecard compliance Nov 3, 2025
@sustainable-computing-io sustainable-computing-io deleted a comment from codecov bot Nov 3, 2025
@vprashar2929 vprashar2929 marked this pull request as ready for review November 3, 2025 06:36
@vprashar2929
Copy link
Collaborator Author

@github-actions
Copy link
Contributor

github-actions bot commented Nov 3, 2025

📊 Profiling reports are ready to be viewed

⚠️ Variability in pprof CPU and Memory profiles
When comparing pprof profiles of Kepler versions, expect variability in CPU and memory. Focus only on significant, consistent differences.

💻 CPU Comparison with base Kepler
File: kepler
Build ID: 9f0cae20e251ec1ea4f230b434a3be68140f11ab
Type: cpu
Time: 2025-11-03 06:41:21 UTC
Duration: 120s, Total samples = 4.13s ( 3.44%)
Active filters:
   show=github.com/sustainable-computing-io
Showing nodes accounting for 0.12s, 2.91% of 4.13s total
Dropped 1 node (cum <= 0.02s)
      flat  flat%   sum%        cum   cum%
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculatePower
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).refreshSnapshot
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).scheduleNextCollection.func1
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh.func1
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh
         0     0%     0%      0.09s  2.18%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).refreshProcesses
     0.07s  1.69%  1.69%      0.07s  1.69%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).CPUTime
         0     0%  1.69%      0.07s  1.69%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).updateProcessCache
         0     0%  1.69%      0.06s  1.45%  github.com/sustainable-computing-io/kepler/internal/resource.populateProcessFields
     0.03s  0.73%  2.42%      0.03s  0.73%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PowerCollector).collectProcessMetrics
         0     0%  2.42%      0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PowerCollector).Collect
    -0.01s  0.24%  2.18%     -0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/monitor.(*Process).Clone (inline)
    -0.02s  0.48%  1.69%     -0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/resource.(*procFSReader).CPUUsageRatio
     0.02s  0.48%  2.18%      0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).PID
         0     0%  2.18%     -0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh.func3
         0     0%  2.18%     -0.02s  0.48%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).refreshNode
         0     0%  2.18%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/device.(*AggregatedZone).Energy
     0.01s  0.24%  2.42%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/device.Energy.String
    -0.01s  0.24%  2.18%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/device.sysfsRaplZone.Energy
         0     0%  2.18%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PlatformCollector).Collect
         0     0%  2.18%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*cpuInfoCollector).Collect
    -0.01s  0.24%  1.94%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*realProcFS).CPUInfo
         0     0%  1.94%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).Snapshot
         0     0%  1.94%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculateNodePower
     0.01s  0.24%  2.18%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculateVMPower
     0.01s  0.24%  2.42%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*Snapshot).Clone
         0     0%  2.42%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*TerminatedResourceTracker[go.shape.*uint8]).Add
     0.01s  0.24%  2.66%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/monitor.newProcess (inline)
         0     0%  2.66%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).ReadAll
     0.01s  0.24%  2.91%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).readPowerSubsystem
         0     0%  2.91%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*Service).Power
         0     0%  2.91%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.(*procFSReader).AllProcs
     0.01s  0.24%  3.15%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).Cgroups
    -0.01s  0.24%  2.91%     -0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).Comm
     0.01s  0.24%  3.15%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.WrapProc (inline)
         0     0%  3.15%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.computeTypeInfoFromProc.func1
         0     0%  3.15%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.containerInfoFromProc
         0     0%  3.15%      0.01s  0.24%  github.com/sustainable-computing-io/kepler/internal/resource.newProcess
    -0.01s  0.24%  2.91%     -0.01s  0.24%  maps.Copy[go.shape.map[github.com/sustainable-computing-io/kepler/internal/device.EnergyZone]github.com/sustainable-computing-io/kepler/internal/monitor.Usage,go.shape.map[github.com/sustainable-computing-io/kepler/internal/device.EnergyZone]github.com/sustainable-computing-io/kepler/internal/monitor.Usage,go.shape.interface { Energy ; Index int; MaxEnergy github.com/sustainable-computing-io/kepler/internal/device.Energy; Name string; Path string },go.shape.struct { EnergyTotal github.com/sustainable-computing-io/kepler/internal/device.Energy; Power github.com/sustainable-computing-io/kepler/internal/device.Power }] (inline)
💾 Memory Comparison with base Kepler (Inuse)
File: kepler
Build ID: 9f0cae20e251ec1ea4f230b434a3be68140f11ab
Type: inuse_space
Time: 2025-11-03 06:43:21 UTC
Duration: 120.02s, Total samples = 10599.72kB 
Active filters:
   show=github.com/sustainable-computing-io
Showing nodes accounting for -1035.52kB, 9.77% of 10599.72kB total
      flat  flat%   sum%        cum   cum%
         0     0%     0% -2048.16kB 19.32%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).scheduleNextCollection.func1
         0     0%     0%  1024.16kB  9.66%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PowerCollector).Collect
         0     0%     0%  1024.16kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).Snapshot
         0     0%     0%  1024.16kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).ensureFreshData
         0     0%     0% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculatePower
         0     0%     0% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculateProcessPower
         0     0%     0% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).refreshSnapshot
         0     0%     0% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh
         0     0%     0% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh.func1
-1023.99kB  9.66%  9.66% -1023.99kB  9.66%  github.com/sustainable-computing-io/kepler/internal/monitor.newProcess (inline)
         0     0%  9.66%  -528.17kB  4.98%  github.com/sustainable-computing-io/kepler/internal/resource.computeTypeInfoFromProc.func2
 -528.17kB  4.98% 14.64%  -528.17kB  4.98%  github.com/sustainable-computing-io/kepler/internal/resource.vmInfoFromCmdLine
         0     0% 14.64%  -528.17kB  4.98%  github.com/sustainable-computing-io/kepler/internal/resource.vmInfoFromProc
         0     0% 14.64%   516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PlatformCollector).Collect
  516.64kB  4.87%  9.77%   516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculateNodePower
         0     0%  9.77%   516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).ReadAll
  516.64kB  4.87%  4.90%   516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).readPowerSubsystem
         0     0%  4.90%   516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*Service).Power
 -516.64kB  4.87%  9.77%  -516.64kB  4.87%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh
💾 Memory Comparison with base Kepler (Alloc)
File: kepler
Build ID: 9f0cae20e251ec1ea4f230b434a3be68140f11ab
Type: alloc_space
Time: 2025-11-03 06:43:21 UTC
Duration: 120.02s, Total samples = 164.57MB 
Active filters:
   show=github.com/sustainable-computing-io
Showing nodes accounting for 6.34MB, 3.85% of 164.57MB total
Dropped 3 nodes (cum <= 0.82MB)
      flat  flat%   sum%        cum   cum%
         0     0%     0%     9.47MB  5.75%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PowerCollector).Collect
    7.50MB  4.56%  4.56%     7.50MB  4.56%  github.com/sustainable-computing-io/kepler/internal/monitor.newProcess (inline)
   -0.51MB  0.31%  4.25%     6.99MB  4.25%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculateProcessPower
         0     0%  4.25%     5.97MB  3.63%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).Snapshot
   -0.50MB  0.31%  3.94%    -4.56MB  2.77%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh
         0     0%  3.94%     4.47MB  2.72%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).ensureFreshData
   -1.53MB  0.93%  3.01%    -4.06MB  2.46%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).refreshProcesses
    3.50MB  2.12%  5.14%     3.50MB  2.12%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PowerCollector).collectProcessMetrics
         0     0%  5.14%     2.43MB  1.48%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).calculatePower
         0     0%  5.14%     2.43MB  1.48%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).refreshSnapshot
         0     0%  5.14%     2.43MB  1.48%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh
         0     0%  5.14%     2.43MB  1.48%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).synchronizedPowerRefresh.func1
         0     0%  5.14%    -2.04MB  1.24%  github.com/sustainable-computing-io/kepler/internal/monitor.(*PowerMonitor).scheduleNextCollection.func1
   -2.53MB  1.54%  3.60%    -2.03MB  1.23%  github.com/sustainable-computing-io/kepler/internal/resource.(*procFSReader).AllProcs
         0     0%  3.60%     1.51MB  0.92%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*PlatformCollector).Collect
         0     0%  3.60%     1.51MB  0.92%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).ReadAll
    1.51MB  0.92%  4.52%     1.51MB  0.92%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*PowerReader).readPowerSubsystem
         0     0%  4.52%     1.51MB  0.92%  github.com/sustainable-computing-io/kepler/internal/platform/redfish.(*Service).Power
       1MB  0.61%  5.12%     1.50MB  0.91%  github.com/sustainable-computing-io/kepler/internal/monitor.(*Process).Clone (inline)
         0     0%  5.12%     1.50MB  0.91%  github.com/sustainable-computing-io/kepler/internal/monitor.(*Snapshot).Clone
   -0.50MB   0.3%  4.82%    -1.08MB  0.66%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*cpuInfoCollector).Collect
   -1.03MB  0.62%  4.20%    -1.03MB  0.62%  github.com/sustainable-computing-io/kepler/internal/resource.(*procFSReader).CPUUsageRatio
         0     0%  4.20%    -1.03MB  0.62%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh.func3
         0     0%  4.20%    -1.03MB  0.62%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).refreshNode
   -0.58MB  0.35%  3.84%    -0.58MB  0.35%  github.com/sustainable-computing-io/kepler/internal/exporter/prometheus/collector.(*realProcFS).CPUInfo
    0.52MB  0.31%  4.16%     0.52MB  0.31%  github.com/sustainable-computing-io/kepler/internal/resource.containerInfoFromCgroupPaths
   -0.50MB  0.31%  3.85%    -0.50MB  0.31%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).Cgroups
         0     0%  3.85%    -0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).updateProcessCache
         0     0%  3.85%    -0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.populateProcessFields
   -0.50MB   0.3%  3.55%    -0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.(*procWrapper).Comm
    0.50MB   0.3%  3.85%     0.50MB   0.3%  maps.Copy[go.shape.map[github.com/sustainable-computing-io/kepler/internal/device.EnergyZone]github.com/sustainable-computing-io/kepler/internal/monitor.Usage,go.shape.map[github.com/sustainable-computing-io/kepler/internal/device.EnergyZone]github.com/sustainable-computing-io/kepler/internal/monitor.Usage,go.shape.interface { Energy ; Index int; MaxEnergy github.com/sustainable-computing-io/kepler/internal/device.Energy; Name string; Path string },go.shape.struct { EnergyTotal github.com/sustainable-computing-io/kepler/internal/device.Energy; Power github.com/sustainable-computing-io/kepler/internal/device.Power }] (inline)
         0     0%  3.85%    -0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).Refresh.func1
   -0.50MB   0.3%  3.55%    -0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.(*resourceInformer).refreshContainers
    0.50MB   0.3%  3.85%     0.50MB   0.3%  github.com/sustainable-computing-io/kepler/internal/resource.WrapProc (inline)

⬇️ Download the Profiling artifacts from the Actions Summary page

📦 Artifact name: profile-artifacts-2345

🔧 Or use GitHub CLI to download artifacts:

gh run download 19025979911 -n profile-artifacts-2345

Copy link
Collaborator

@SamYuan1990 SamYuan1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general this PR LGTM to fix all alerts.
Leave some comments, either fixed within this PR or not fine for me.

test-and-codecov:
needs: check-changes
if: needs.check-changes.outputs.changes == 'true'
permissions:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a question here for this.
if https://github.com/sustainable-computing-io/kepler/pull/2345/files#diff-7a6a4578fe04c4fc86b28e2dc9672e48d1a9f721315e540b90bac0ef12263053R6-R8 set global permission for all jobs, why do we need a permission setting at here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When using reusable workflows (jobs with the uses: keyword), permissions are not inherited from the
global permissions setting at the workflow level. This is a security feature in GitHub Actions.

The global permissions: read-all in the workflow only applies to regular jobs that run steps directly.
For jobs that call reusable workflows, we must explicitly declare what permissions should be passed
to the called workflow.

Without the explicit permissions, the test-and-codecov.yaml workflow would receive
no permissions (or minimal default permissions), which could cause it to fail.

jobs:
test-and-codecov:
permissions:
contents: read
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will codecov write anything? as this job will run after push, can we double check with document or anyway to test it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, Codecov does not write anything to the repository. contents: read is correct and
sufficient.

uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: release-${{ steps.version.outputs.version }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release-${{ github.ref_name }} ?
if in this new design we just have bash here for ... value injection?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes we can use release-${{ github.ref_name }} How about I update it in this #2347 ?

@vprashar2929 vprashar2929 merged commit 826b223 into main Nov 3, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Changes to the CI pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants